package com.zmxstudy.gzu.config;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.module.SimpleModule;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 注入Long类型超标的序列化器
 */
@Configuration
public class JacksonConfig {
    @Bean
    public ObjectMapper objectLongToStringMapper() {
        ObjectMapper objectMapper = new ObjectMapper();
        SimpleModule module = new SimpleModule();
        module.addSerializer(Long.class, new LongToStringSerializer()); // 注册自定义序列化器
        objectMapper.registerModule(module);
        return objectMapper;
    }
}
